﻿using System.Collections.Generic;

namespace ChessKit.Logic
{
  partial class Board
  {
    private void GenerateMoves(Piece piece, int fromSquare, 
       int? enPassantFile, CastlingAvailability castlingAvailability, List<HintedMove> collector)
    {
      var squares = ProtoBoard.Squares;
      switch (piece)
      {
        #region ' White Pawn '
        case Piece.WhitePawn:
          GenerateWhitePawnMoves(fromSquare, enPassantFile, collector);
          break;
        #endregion

        #region ' White Bishop '
        case Piece.WhiteBishop:
          for (var to = fromSquare + 17; (to & 0x88) == 0; to += 17)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteBishop;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteBishop;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -15; (to & 0x88) == 0; to += -15)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteBishop;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteBishop;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -17; (to & 0x88) == 0; to += -17)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteBishop;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteBishop;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 15; (to & 0x88) == 0; to += 15)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteBishop;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteBishop;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          break;
        #endregion

        #region ' White Knight '
        case Piece.WhiteKnight:
          {
            var to = fromSquare + 33;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + 31;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + -31;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + -33;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + 18;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + 14;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + -14;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + -18;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteKnight;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          break;
        #endregion

        #region ' White Rook '
        case Piece.WhiteRook:
          for (var to = fromSquare + 16; (to & 0x88) == 0; to += 16)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteRook;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteRook;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 1; (to & 0x88) == 0; to += 1)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteRook;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteRook;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -16; (to & 0x88) == 0; to += -16)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteRook;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteRook;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -1; (to & 0x88) == 0; to += -1)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteRook;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteRook;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          break;
        #endregion

        #region ' White Queen '
        case Piece.WhiteQueen:
          for (var to = fromSquare + 16; (to & 0x88) == 0; to += 16)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 1; (to & 0x88) == 0; to += 1)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -16; (to & 0x88) == 0; to += -16)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -1; (to & 0x88) == 0; to += -1)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 17; (to & 0x88) == 0; to += 17)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -15; (to & 0x88) == 0; to += -15)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -17; (to & 0x88) == 0; to += -17)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 15; (to & 0x88) == 0; to += 15)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.WhiteQueen;
                if (!IsAttackedByBlack(WhiteKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.WhiteQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          break;
        #endregion

        #region ' White King '
        case Piece.WhiteKing:
          {
            var to = fromSquare + 16;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            }
          }
          {
            var to = fromSquare + 17;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            }
          }
          {
            var to = fromSquare + 1;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            }
          }
          {
            var to = fromSquare + -15;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            }
          }
          {
            var to = fromSquare + -16;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            }
          }
          {
            var to = fromSquare + -17;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            }
          }
          {
            var to = fromSquare + -1;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            }
          }
          {
            var to = fromSquare + 15;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            else if ((toPiece & (byte)PieceColor.White) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByBlack(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.WhiteKing;
            }
            }
          }
          GenerateWhiteCastlingMoves(fromSquare, castlingAvailability, collector);
          break;
        #endregion

        #region ' Black Pawn '
        case Piece.BlackPawn:
          GenerateBlackPawnMoves(fromSquare, enPassantFile, collector);
          break;
        #endregion

        #region ' Black Bishop '
        case Piece.BlackBishop:
          for (var to = fromSquare + 17; (to & 0x88) == 0; to += 17)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackBishop;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackBishop;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -15; (to & 0x88) == 0; to += -15)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackBishop;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackBishop;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -17; (to & 0x88) == 0; to += -17)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackBishop;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackBishop;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 15; (to & 0x88) == 0; to += 15)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackBishop;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackBishop;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Bishop  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackBishop;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Bishop  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          break;
        #endregion

        #region ' Black Knight '
        case Piece.BlackKnight:
          {
            var to = fromSquare + 33;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + 31;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + -31;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + -33;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + 18;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + 14;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + -14;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          {
            var to = fromSquare + -18;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackKnight;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Knight  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackKnight;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Knight  | MoveHints.Capture));
              }
            }
            }
          }
          break;
        #endregion

        #region ' Black Rook '
        case Piece.BlackRook:
          for (var to = fromSquare + 16; (to & 0x88) == 0; to += 16)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackRook;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackRook;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 1; (to & 0x88) == 0; to += 1)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackRook;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackRook;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -16; (to & 0x88) == 0; to += -16)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackRook;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackRook;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -1; (to & 0x88) == 0; to += -1)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackRook;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackRook;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Rook  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackRook;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Rook  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          break;
        #endregion

        #region ' Black Queen '
        case Piece.BlackQueen:
          for (var to = fromSquare + 16; (to & 0x88) == 0; to += 16)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 1; (to & 0x88) == 0; to += 1)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -16; (to & 0x88) == 0; to += -16)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -1; (to & 0x88) == 0; to += -1)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 17; (to & 0x88) == 0; to += 17)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -15; (to & 0x88) == 0; to += -15)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + -17; (to & 0x88) == 0; to += -17)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          for (var to = fromSquare + 15; (to & 0x88) == 0; to += 15)
          {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen ));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen ));
              }
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              if ((PinsMap & (1ul << fromSquare)) != 0)
              {
                squares[fromSquare] = (byte)Piece.EmptyCell;
                squares[to] = (byte)Piece.BlackQueen;
                if (!IsAttackedByWhite(BlackKingPosition))
                  collector.Add(new HintedMove(this, fromSquare, to, 
                    MoveHints.Queen  | MoveHints.Capture));
                squares[to] = toPiece;
                squares[fromSquare] = (byte)Piece.BlackQueen;
              }
              else
              {
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.Queen  | MoveHints.Capture));
              }
              break;
            }
            else break;
          }
          break;
        #endregion

        #region ' Black King '
        case Piece.BlackKing:
          {
            var to = fromSquare + 16;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            }
          }
          {
            var to = fromSquare + 17;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            }
          }
          {
            var to = fromSquare + 1;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            }
          }
          {
            var to = fromSquare + -15;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            }
          }
          {
            var to = fromSquare + -16;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            }
          }
          {
            var to = fromSquare + -17;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            }
          }
          {
            var to = fromSquare + -1;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            }
          }
          {
            var to = fromSquare + 15;
            if ((to & 0x88) == 0)
            {
            var toPiece = squares[to];
            if (toPiece == 0) 
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King ));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            else if ((toPiece & (byte)PieceColor.Black) == 0)
            {
              squares[fromSquare] = (byte)Piece.EmptyCell;
              if (!IsAttackedByWhite(to))
                collector.Add(new HintedMove(this, fromSquare, to, 
                  MoveHints.King  | MoveHints.Capture));
              squares[fromSquare] = (byte)Piece.BlackKing;
            }
            }
          }
          GenerateBlackCastlingMoves(fromSquare, castlingAvailability, collector);
          break;
        #endregion

      }
    }
  }
}

